class Wine
	 def initialize()
		@log = Logger.new(STDOUT)
		@producer = ""
		@source = "n/a"
		@country = ""
		@region = ""
		@area = ""
		@year = 0
		@ean = ""
		@category = ""
		@type = ""
		@alcohol = ""
		@name = "Unknown wine"
	end
	
	# Who made the wine
	attr_accessor :producer
	
	# Where was this information found
	attr_accessor :source
	
	# When was the wine made
	attr_accessor :year
	
	#Where does the wine come from
	attr_accessor :country, :region, :area
	
	attr_accessor :ean, :category, :type, :alcohol, :name
	
	def to_s
		"Wine Description for \"" + @name +  	"\"\n"+
		"\t- Producer: " + @producer + "\n" +
		"\t- Source:   " + @source + "\n" +
		"\t- Country:  " + @country + "\n" +
		"\t- Region:   " + @region + "\n" +
		"\t- Area:     " + @area + "\n" +
		"\t- Category: " + @category + "\n" +
		"\t- Type:     " + @type + "\n" +
		"\t- Alcohol:  " + @alcohol + "\n" +
		"\t- Year:     " + @year.to_s + "\n" + 
		"\t- EAN:      " + @ean
	
	end
	
	#####################################################################################
	# Check whether all information is already set or if this wine needs some updating
	#####################################################################################
	def needsLookup
		$log.debug "Checking if this wine needs an update"
		result = false
		
		if @producer == nil || @producer == "" then
			$log.debug "No producer set => we need a check"
			result = true
		end
		
		if @name == nil || @name == "" then
			$log.debug "No name set => we need a check"
			result = true
		end
		
		if @type == nil || @type == "" then
			$log.debug "No type set => we need a check"
			result = true
		end
		
		if @category == nil || @category == "" then
			$log.debug "No category set => we need a check"
			result = true
		end

		if @region == nil || @region == "" then
			$log.debug "No region set => we need a check"
			result = true
		end
		
		if @area == nil || @area == "" then
			$log.debug "No area set => we need a check"
			result = true
		end
		
		if @country == nil || @country == "" then
			$log.debug "No country set => we need a check"
			result = true
		end
		
		if @year == nil || @year == "" || @year == 0 then
			$log.debug "No year set => we need a check"
			result = true
		end
		
		if @ean == nil then
			$log.debug "No EAN set => Skip update"
			# Not having an EAN will make the whole thing fail. So this should be at the end
			result = false
		end
		
		result
	end
	
end